home *** CD-ROM | disk | FTP | other *** search
/ Freelog 45 / Freelog045.iso / Bas / Internet / Trellian / twp103.exe / {app} / wdghtml40 / hideNonStrict.js < prev    next >
Text File  |  2003-02-08  |  2KB  |  77 lines

  1. var newRules = new Array();
  2. var hideNonStrictAction = null;
  3.  
  4. function writeButton(what) {
  5.   if (document.styleSheets && (document.all || document.getElementById)
  6.     && document.styleSheets[0] != null)
  7.   {
  8.     document.write("<p><input type=button value=\"Hide non-strict " + what
  9.       + "\" id=toggler accesskey=s onclick=\"toggleNonStrict('"
  10.       + what + "')\"></p>");
  11.   }
  12. }
  13.  
  14. function toggleNonStrict(what) {
  15.   var sheet = document.styleSheets[0];
  16.   var toggler = null;
  17.  
  18.   if (document.all) {
  19.     toggler = document.all.toggler;
  20.  
  21.     if (toggler != null) {
  22.       if (toggler.value == "Hide non-strict " + what) {
  23.         sheet.addRule(".transitional", "display:none");
  24.         newRules.push(sheet.rules.length - 1);
  25.  
  26.         sheet.addRule(".transitional", "speak:none");
  27.         newRules.push(sheet.rules.length - 1);
  28.  
  29.         sheet.addRule(".frameset", "display:none");
  30.         newRules.push(sheet.rules.length - 1);
  31.       
  32.         sheet.addRule(".frameset", "speak:none");
  33.         newRules.push(sheet.rules.length - 1);
  34.       
  35.         if (hideNonStrictAction != null) {
  36.           hideNonStrictAction(true);
  37.         }
  38.         toggler.value = "Show non-strict " + what;
  39.  
  40.       } else {
  41.         while (newRules.length > 0) {
  42.           sheet.removeRule(newRules.pop());
  43.         }
  44.         if (hideNonStrictAction != null) {
  45.           hideNonStrictAction(false);
  46.         }
  47.         toggler.value = "Hide non-strict " + what;
  48.       }
  49.     }
  50.  
  51.   } else {
  52.     toggler = document.getElementById('toggler');
  53.  
  54.     if (toggler != null) {
  55.       if (toggler.value == "Hide non-strict " + what) {
  56.         newRules.push(sheet.insertRule(".transitional {display:none}",sheet.cssRules.length));
  57.         newRules.push(sheet.insertRule(".transitional {speak:none}",sheet.cssRules.length));
  58.         newRules.push(sheet.insertRule(".frameset {display:none}",sheet.cssRules.length));
  59.         newRules.push(sheet.insertRule(".frameset {speak:none}",sheet.cssRules.length));
  60.  
  61.         if (hideNonStrictAction != null) {
  62.           hideNonStrictAction(true);
  63.         }
  64.         toggler.value = "Show non-strict " + what;
  65.       } else {
  66.         while (newRules.length > 0) {
  67.           sheet.deleteRule(newRules.pop());
  68.         }
  69.         if (hideNonStrictAction != null) {
  70.           hideNonStrictAction(false);
  71.         }
  72.         toggler.value = "Hide non-strict " + what;
  73.       }
  74.     }
  75.   }
  76. }
  77.